<template>
  <div>
     <breadcrumb></breadcrumb>
     <el-divider content-position="left">未审批店铺申请</el-divider>
     <el-table
      :data="examine.result"
      style="width: 100%"
      >
        <el-table-column
          prop="corporation_name"
          label="店铺名称"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="corporation_pwd"
          label="店铺密码"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="corporation_phone"
          label="店铺电话"
          align="center"
        >
        </el-table-column>
        <el-table-column
          label="申请图片1"
          align="center"
        >
          <template slot-scope="scope">
            <el-image
            style="width: 100px; height: 100px"
            :src="scope.voucher1"
            fit="cover"></el-image>
          </template>
        </el-table-column>
        <el-table-column
          label="申请图片2"
          align="center"
        >
          <template slot-scope="scope">
            <el-image
            style="width: 100px; height: 100px"
            :src="scope.voucher2"
            fit="cover"></el-image>
          </template>
        </el-table-column>
          <el-table-column
          fixed="right"
          label="操作"
          align="center"
        >
        <template slot-scope="scope">
            <el-button type="success" icon="el-icon-check" circle  @click="modify(scope.row.corporation_id, 2)" ></el-button>
            <el-button type="danger" icon="el-icon-close" circle @click="modify(scope.row.corporation_id, 1)"></el-button>
          </template>        
      </el-table-column>
    </el-table>  
    <br>
      <!-- 分页 -->
    <el-pagination
      background
      :total=examine.total
      :page-size=examine.pagesize
      layout=" ->,prev, pager, next,total,jumper"
      @current-change="ChangCurrentPage"
    >
    </el-pagination>
    
    <!-- 对话框 -->
    <el-dialog title="撤销因素" :visible.sync="examineVisible">
      <el-form :model="form" :rules="rules" ref="form">
        <el-form-item prop="cause">
          <el-input
            type="textarea"
            :rows="2"
            placeholder="请输入撤销因素"
            v-model="form.cause">
          </el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="resetForm('form')">取 消</el-button>
        <el-button type="primary" @click="submitForm('form')">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import breadcrumb  from '../components/breadcrumb';
import httpApi from "@/http";
  export default {
    components:{ breadcrumb},
    data() {
      return {
        examine:{
            page: 1,
            pagesize:5,
            result:[],
            total:1
          },
          examineVisible:false,
          form:{
            cause:'',
          },
          rules: {
            cause: [
              { required: true, message: '请输入具体因素', trigger: 'blur' },
              { min: 3, max: 10, message: '长度在 3 到 200 个字符', trigger: 'blur' }
            ],
          },
      }
    },
    methods: {
      // 弹窗
      resetForm(form) {
        this.$refs[form].resetFields();
        this.examineVisible = false
      },
      submitForm(form) {
        this.$refs[form].validate((valid) => {
          if (valid) {
            this.$message({
              message: '感谢填写',
              type: 'success'
            });
          }else {
            this.$message({
              showClose: true,
              message: '失败',
              type: 'error'
            });
          }
        })
      },
      // 修改
      modify(id,num){
        if(num === 1){
          this.examineVisible = true
        }else if(num === 2){
          this.form.cause = '成功'
        }
        let params = {corporation_id: id , corporation_type: num , result: this.form.cause}
        httpApi.examineApi.queryExamineById(params).then(res =>{
          console.log(res);
           if(res.data.code === 200){
            this.$message({
              message: '修改成功',
              type: 'success'
            });
            this.inexamine()
           }else{
            this.$message({
              showClose: true,
              message: '失败',
              type: 'error'
            });
           }
        })
      },
      // 数据
      inexamine(){
        let params = {page: this.examine.page ,pagesize: this.examine.pagesize}
        httpApi.examineApi.queryUnExamineList(params).then(res =>{
          console.log("店铺列表",res);
          this.examine = res.data.data
        })
      },
      //变化当前页
      ChangCurrentPage(page){
          // console.log("当前页数",page);
          this.store.page = page
          this.search()
      },
    },
    mounted(){
      this.inexamine()
    },
  }
</script>

<style >

</style>